package com.codeyang.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.codeyang.domain.Prod;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 描述: TO-删除标志-DO
 *
 * @author CodeYang_Site
 * @version 2021/5/24 22:34
 */
@Mapper
public interface ProdMapper extends BaseMapper<Prod> {

    /**
     * 根据商品id修改库存和销量
     *
     * @param proId
     * @param count
     * @return
     */
    @Update(" update prod set total_stocks = total_stocks + #{count} ,sold_num = sold_num - #{count} where prod_id =  #{proId} and total_stocks + #{count} >= 0 ")
    int changeStock(@Param("proId") Long proId, @Param("count") Integer count);
}